package com.earstep.proxy
{
	import com.erastep.mvc.proxy.Proxy;
	import com.erastep.util.CommonConstants;
	import com.erastep.util.LogUtil;
	import com.erastep.util.StringUtil;
	
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	
	/**
	 * @depart 宁波维涛
	 * @author Jarvis 
	 * @E-mail: shaomj@victopsoft.com
	 * @version 1.0.1 
	 * 创建时间：2011-11-9 下午02:06:47 * 
	 */
	public class LoginProxy extends Proxy
	{
		
		public static var NAME:String = "LoginProxy";
		
		public function LoginProxy()
		{
			super(NAME);
		}
		
		public function checkUser(obj:Object):void{
			sendByRemote({
				action:"Login",
				method:"login",
				fail:loginFail,
				success:loginSuccess
			}).send(obj.userName,obj.passWord);
		}
		
		/**
		 * 登录成功
		 * */
		private function loginSuccess(e:ResultEvent):void{
			var result:Object = StringUtil.JsonDecode(e.result.toString());
			if(result && result.code == "0"){
				LogUtil.print("用户名或者密码错误!");
			}else if(result && result.code == "1"){
				sendNotification("getPluginSuccess",result);
			}
		}
		
		/**
		 * 访问服务器失败
		 * */
		private function loginFail(e:FaultEvent):void{
			LogUtil.print("连接服务器端出现错误!");
		}
	}
}